home *** CD-ROM | disk | FTP | other *** search
- global bulletData, bulletSO, maxBullets, playerLocData, enemyData
-
- on initializeBullets
- bulletData = []
- repeat with wBullet = 1 to maxBullets
- wSprite = wBullet + bulletSO
- add(bulletData, [1, point(random(5000), 3000), point(random(50) - 25, random(15)), 0, 0])
- set the member of sprite wSprite to "Pearl"
- end repeat
- bulletData[1][1] = 1
- end
-
- on updateBulletDisplay
- totalBullets = 0
- repeat with wScan = 1 to count(bulletData)
- if bulletData[wScan][1] = 0 then
- totalBullets = totalBullets + 1
- end if
- end repeat
- member("Pearls Display").text = string(totalBullets)
- end
-
- on launchBullet
- validSlot = 0
- totalBullets = 0
- repeat with wScan = 1 to count(bulletData)
- if bulletData[wScan][1] = 0 then
- if validSlot = 0 then
- validSlot = wScan
- end if
- end if
- end repeat
- if validSlot <> 0 then
- spawnloc = point(playerLocData[2], 3650)
- targloc = the mouseLoc * 10
- fireAim = findAngle(spawnloc, targloc)
- locY = cos(fireAim * PI / 180) * -200
- locX = sin(fireAim * PI / 180) * 200
- bulletData[validSlot] = [1, spawnloc, point(locX, locY), 1, 1]
- updateBulletDisplay()
- playSound("Shoot", 4)
- end if
- end
-
- on moveBullets
- global rendEnemyAsunder
- repeat with wBullet = 1 to count(bulletData)
- wSprite = wBullet + bulletSO
- if bulletData[wBullet][1] = 1 then
- bulletData[wBullet][4] = bulletData[wBullet][4] + 1
- bLoc = bulletData[wBullet][2]
- bSpeed = bulletData[wBullet][3]
- bSpeed = bSpeed + point(0, 2)
- if bLoc[1] > 5800 then
- bSpeed[1] = 0 - abs(bSpeed[1])
- else
- if bLoc[1] < 0 then
- bSpeed[1] = abs(bSpeed[1])
- end if
- end if
- if bLoc[2] > 3800 then
- bSpeed[2] = 0 - (abs(bSpeed[2]) / 3)
- if bSpeed[2] > -25 then
- bSpeed[2] = 0
- end if
- bSpeed[1] = bSpeed[1] / 2
- bLoc[2] = 3800
- end if
- bulletData[wBullet][3] = bSpeed
- bLoc = bLoc + bSpeed
- bulletData[wBullet][2] = bLoc
- if findDistance(point(0, 0), bSpeed) > 20 then
- if random(3) = 1 then
- addparticle(bLoc, 0, 1)
- end if
- end if
- revertToplayer = 0
- if bulletData[wBullet][4] > 10 then
- grabDist = findDistance(point(playerLocData[2], 3650), bulletData[wBullet][2])
- if grabDist <= 300 then
- revertToplayer = 1
- end if
- end if
- playRendAsunderSOund = 0
- rendEnemyAsunder = 0
- if bulletData[wBullet][5] = 1 then
- repeat with wEnemy = 1 to count(enemyData)
- if (rendEnemyAsunder = 0) and (enemyData[wEnemy][1] = 1) then
- if [1, 1, 1, 0, 0, 0][enemyData[wEnemy][2]] = 1 then
- rendDist = findDistance(enemyData[wEnemy][3], bulletData[wBullet][2])
- if rendDist <= 175 then
- rendEnemyAsunder = wEnemy
- playRendAsunderSOund = 1
- end if
- end if
- end if
- end repeat
- end if
- if rendEnemyAsunder <> 0 then
- enemyData[rendEnemyAsunder][5] = enemyData[rendEnemyAsunder][5] + 1
- bulletData[wBullet][5] = 0
- bulletData[wBullet][3] = point(0, 0) - (bulletData[wBullet][3] / 4)
- repeat with wEffect = 1 to 6
- addparticle(bulletData[wBullet][2], 0, 2)
- end repeat
- end if
- if revertToplayer = 1 then
- bulletData[wBullet][1] = 0
- set the loc of sprite wSprite to point(-50, -50)
- updateBulletDisplay()
- next repeat
- end if
- set the loc of sprite wSprite to bLoc / 10
- end if
- end repeat
- if playRendAsunderSOund = 1 then
- playSound("Hit Enemy", 2)
- end if
- end
-